from test_case.test_requst.allure import *

class dingding():
    def inform(self):
        da  = date('%Y-%m-%d')
        data = report_get()#调获取测试报告内容
        print(data)
        Fail = data[1]  # 失败的用例数
        Pass = data[2]  # 成功的用例数
        Sum = data[0]  # 用例总数

        # 钉钉接口与机器人token,编辑access_token
        url = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxx"

        # 头部信息(Content-Type必填)
        header = {
            "Content-Type": "application/json",
            "Charset": "UTF-8"
        }
        msg = "#自动化测试报告:本次自动化测试报告已发至邮箱！ #\n"\
              "时    间:  %s\n" \
              "总用例数:  %s\n" \
              "成功用例数:  %s\n" \
              "失败用例数:  %s\n"  % (da, Sum, Pass ,Fail)

        payload = {
            "msgtype": "text",
            "text": {
                "content": msg  # 抓取数据发送的内容放到msg
            },
            "at": {
                # "isAtAll": True,  # @全体成员（在此可设置@特定某人）
                    "isAtAll": '@球球'
            }
        }

        # r = session().post(url=url, json=payload, headers=header)
        # print(r.json())  # 打印接口请求返回结果


if __name__ == "__main__":

    dingding().inform()
